<template>
    <div class="box">
        <Tabs v-model="currentTab" @on-click="handleSelectTab" name="b" :animated="false">
            <TabPane :index="0" tab="b" name="callback" label="回访">
                <return-visit :currentIndex="currentIndex" ref="callback"></return-visit>
            </TabPane>
            <TabPane :index="1" v-if="patientInfo.is_show_echat" tab="b" name="echat" label="E聊">
                <chart-list ref="chatList"></chart-list>
            </TabPane>
            <TabPane :index="2" tab="b" name="log" label="日志">
                <journal ref="journal"></journal>
            </TabPane>
        </Tabs>
    </div>
</template>

<script>
import chartList from './chartList.vue';
import returnVisit from './returnVisit.vue';
import journal from './journal.vue';
import { mapState } from 'vuex';
export default {
    components: {
        chartList, returnVisit, journal
    },
    data() {
        return {
            currentTab: 'callback'
        };
    },
    props: {
        currentIndex: {
            type: Number,
            default: 0
        }
    },
    computed: {
        ...mapState('chatwebsocket/wechat', ['patientInfo'])
    },
    methods: {
        getRetrunVisit() {
            this.$refs['callback'].getCallback();
        },
        handleSelectTab(val) {
            switch (this.currentTab) {
                case 'callback':// 回访
                    this.$refs['callback'].getCallback();
                    break;
                case 'echat':// E聊
                    this.$refs['chatList'].initData();
                    break;
                case 'log':// 日志
                    this.$refs['journal'].getJournal();
                    break;
                default:
                    break;
            }
        }
    }
};
</script>

<style lang="less" scoped>
</style>